package edu.udo.sopra10.chaturaji.entities.terminationconditions;

import edu.udo.sopra10.chaturaji.entities.Game;
import edu.udo.sopra10.chaturaji.entities.Player;
import edu.udo.sopra10.chaturaji.entities.pieces.Piece;

/**
 * {@link Game} termination after the total defeat of a single {@link Player}.
 * Total defeat occurs if a player has no more {@link Piece}s under her control.
 * This does not detect deadlocked positions.
 * 
 * @author Simon Dierl
 */
public final class Elimination extends TerminationCondition {
	/**
	 * Create a new {@link Elimination} for the specified {@link Game}.
	 * 
	 * @param game
	 *            the terminated game, may be {@code null} if not created.
	 */
	public Elimination(final Game game) {
		super(game);
	}

	@Override
	public boolean isGameTerminated() {
		for (final Player player : game.getPlayers()) {
			if (player.getPieces().isEmpty()) {
				return true;
			}
		}
		return false;
	}

}
